	
	'
	'  pack - simple tool for creating packages
	'
	'  compile with fbc -s gui pack.bas
	'
	
	#Include "fbpacker.bi"
	
	ScreenRes 480, 320, 32 
	
	Dim As Integer 	userInput, fn
	Dim As String		pattern, password, outputFile, curFile
	Dim As FB.Packer	package
	
	Do
	
		Cls
		
		Print " Welcome to pack"
		Print
		Print " Select job type:"
		Print "  [1] Pack all files from current directory"
		Print "  [2] Pack all images (*.bmp) from current directory"
		Print "  [3] Pack packlist file"
		Print
		Input "> ", userInput
		Print
		
		Select Case As Const userInput
			
			Case 1
				
				Input " enter file pattern: ", pattern
				Input " enter password: ", password
				Input " enter output file name: ", outputFile
				
				curFile = Dir(pattern)
				
				While Len(curFile) > 0
					
					package.AddFile curFile, curFile
					
					curFile = Dir
						
				Wend
				
				package.Save outputFile, password 
				
				
			Case 2
				
				Input " enter password: ", password
				Input " enter output file name: ", outputFile
				
				curFile = Dir("*.bmp")
				
				While Len(curFile) > 0
					
					package.AddBMPImage curFile, curFile
					
					curFile = Dir
						
				Wend
				
				package.Save outputFile, password
				
				
			Case 3
				
				Input " enter path to packlistfile: ", curFile
				Input " enter password: ", password
				Input " enter output file name: ", outputFile
				
				fn = FreeFile
				
				Dim As String fileType, fileLabel, fileName
				
				If Open(curFile For Input As #fn) = 0 Then
					
					While Not Eof(fn)
						
						Input #fn, fileType, fileLabel, fileName
						
						If LCase(fileType) = "image" Then
							
							package.AddBMPImage fileLabel, fileName
								
						Else
							
							package.AddFile fileLabel, fileName
							
						EndIf
						
					Wend
					
					Close #fn
					
					package.Save outputFile, password
					
				EndIf
				
			Case Else
				
				Continue Do
			
		End Select
		
		Print
		Print " What you want to do now:"
		Print
		Print "  [1] Pack some more files!"
		Print "  [anything else] Exit"
		Print
		Input "> ", userInput
		
		package.Clear
		
		If userInput = 1 Then Continue Do
		
		Exit Do
	
	Loop
	